package com.selenium;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.util.concurrent.TimeUnit;

/**
 * Created by c2611 on 23.06.2014.
 */
public class GoogleTestSearch {

    WebDriver driver = new FirefoxDriver();

    @BeforeClass
    public void setUp() {

        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

        driver.manage().window().maximize();
        driver.get("http://www.google.com.ua");
    }

    @Test
    public void searchTest() {
        WebElement searchField = driver.findElement(By.id("gbqfq"));
        searchField.sendKeys("Selenium");
        WebElement seleniumLink = driver.findElement(By.xpath(".//*[@id='rso']/div/li[1]/div/h3/a/em"));
        Assert.assertEquals(seleniumLink.getText().toString().contains("Selenium"), true);

    }

    @AfterClass
    public void tearDown() {
        driver.quit();
    }

}
